<%@ page language="java" contentType="text/html; charset=utf-8"  pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
	<title>按配送企业设置医疗机构</title>
	<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>按配送企业设置医疗机构</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">目录管理</a></li>
            <li class="active"><a href="#">配送关系管理</a></li>
            <li class="active"><a href="#">配送关系查看</a></li>
        </ol>
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class="form-inline">
                 <div class="form-group form-group-xs">
					<label>企业编码：</label> <input class="form-control" type="text"
						name="compCode" id="delCompCode" placeholder="企业编码" maxlength="25" /> 
				</div>
				<div class="form-group form-group-xs">
					<label>企业名称：</label> <input class="form-control" type="text"
						name="compName" id="delCompName" placeholder="企业名称" maxlength="64" /> 
				</div>
                    <button type="button"  onclick="search()"  class="btn btn-success btn-sm">查&nbsp;询</button>
                </div>
            </div>
        </div>
         
        <table class="jqgrid" id="gridList"></table>
        <div id="prowed2"></div>
        
		<div class=" box box-warning bottongroup" id="bottongroup">
		<label  onclick="window.location.href='${ctx}/baseGoods/toProjDrugList.html'"   class="btn btn-default btn-sm" >返 回</label>
		</div>
<div style="margin-top: 10px;"></div>
<form action="${ctx}/baseGoods/toHospJsp.html" method="post" id="form">
		<input type="hidden" id="compCode" name="compCode">
		<input type="hidden" id="compName" name="compName">
		</form>
		<form action="${ctx}/baseGoods/toDelHospJsp.html" method="post" id="form2">
		<input type="hidden" id="compCode2" name="compCode">
		<input type="hidden" id="compName2" name="compName">
		</form>
</section>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">
$(function () {
$('.form-inline :input').bind('keydown', function(event) {if (event.keyCode == "13") {search();}}).eq(1).focus();
jQuery("#gridList").jqGrid({
	url: "${ctx}/baseGoods/getDelCompList.html",
    mtype: "POST",
	datatype: "json",
	autowidth: true,
	height: 270,
   	colNames:['操作','已设置医疗机构数','企业编码','企业名称','组织机构代码','联系人','联系电话'],
   	colModel:[
   	   	{name:'oper',index:'formName', width:140, align:"center", sortable:false,formatter:function(val,option,rowdata){
   			var str = "<a href=\"javaScript:toDelHospJsp('"+rowdata.compCode+"','"+rowdata.compName+"');\">选择医疗机构</a>";
   			str += "<a href='${ctx}/baseGoods/toDelRelHospLog.html?delCompCode="+rowdata.compCode+"&delCompName="+rowdata.compName+"'>设置日志</a>";
   			return str;
   		}},
   		{name:'hospCount',index:'formName', width:60, align:"center", sortable:false,formatter:function(val,option,rowdata){
   			var str = "<a href=\"javaScript:toHospJsp('"+rowdata.compCode+"','"+rowdata.compName+"');\">"+val+"</a>";
	   			return str;
   		}},
		{name:'compCode',index:'goodsCode', width:100,align:"center", sortable:false},
		{name:'compName',index:'goodsCode', width:140,align:"left", sortable:false},
   		{name:'orgCode',index:'drugName', width:120,align:"center", sortable:false},
   		{name:'contactName',index:'compName', width:120, sortable:false},
   		{name:'contactPhone',index:'areaName', width:120, sortable:false}
   	],
	 rowNum: 20,
     rowList: [10, 20, 50,100],
     rownumbers: true,
     pager: "#prowed2",
     viewrecords: true,
     caption: "配送企业列表",
     editurl:"proPlanItemListHis.jsp",
     gridComplete:function(){
         autoRNWidth("gridList");
         selectByOneData("gridList");
     },
     jsonReader: {
         repeatitems: false,
         id: "ids"
     }
   	
});
	jQuery("#gridList").jqGrid('navGrid',"prowed2",{edit:false,add:false,del:false});
});

function search() {
	var compCode = $.trim($("#compCode").val());
	var compName = $.trim($("#compName").val());
	$("#gridList").jqGrid('setGridParam',{  
        datatype:'json',
        postData:{
        	"compCode":compCode,
        	"compName":compName,
        	"projID":"${param.projID}",
        		"goodsCode":"${param.goodsCode}"}
    }).trigger("reloadGrid"); //重新载入  
}
//查看已设置的医疗机构
function toHospJsp(compCode,compName){
	$("#compCode").val(compCode);
	$("#compName").val(compName);
	$("#form").submit();
}
//选择医疗机构
function toDelHospJsp(compCode,compName){
	$("#compCode2").val(compCode);
	$("#compName2").val(compName);
	$("#form2").submit();
}
</script>
</body>
</html>